package com.sky.controller.user;

import com.sky.anno.UserRdis;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "菜品管理")
@RestController
@RequestMapping("/user/dish")
public class UserDishController {

    @Autowired
    private DishService dishService;

    /**
     * 查询菜品
     * @param categoryId
     * @return
     */
//    @UserRdis("dish_")
    @Cacheable(cacheNames = "dish",key = "#a0")
    @ApiOperation("查询菜品")
    @GetMapping("/list")
    public Result<List<DishVO>> list(@RequestParam Long categoryId){
        log.info("查询菜品：{}",categoryId);
        List<DishVO> list = dishService.getList(categoryId);
        return Result.success(list);
    }


}
